import { INCREMENT, DECREMENT, MULTIPLY } from "./constants"
const initState = {
  count: 0,
  msg: "hello Redux",
  color: "hello",
}
function reducer(state = initState, action) {
  switch (action.type) {
    case INCREMENT:
      return {
        ...state,
        count: state.count + action.num,
        msg: "点击加数!",
        color: "red",
      }
    case DECREMENT:
      return {
        ...state,
        count: state.count - action.num,
        msg: "点击减数!",
        color: "blue",
      }
    case MULTIPLY:
      return {
        ...state,
        count: state.count * action.num,
        msg: "点击乘2!",
        color: "orange",
      }
    default:
      return state
  }
}

export default reducer
